/*
 * This class is the manager for all the Valloy Parsing
 * business login.  We may add other helpers classes
 * to keep the business logic kind of independent during the development
 * process.
 */

package edu.ut.ece382c.valloy.ui;
import edu.ut.ece382c.valloy.parser.*;
import edu.ut.ece382c.valloy.converter.*;

/**
 *
 * @author vasr
 */
public class ValloyParser {

    //TODO:
    static StrConverter converter = null;

    public ValloyParser()    {
     converter = null;
    }

    public ValloyParser(String filepath)
    {
        converter = new StrConverter(filepath);

    }

    //Parse Classes
    public String ParseClassHierarchy()
    {
        //Step 1: Compute the hierarchy of class declarations
        //Step 2: Construct Sig Class and Sig Objects
        //step 3; Change Class declaration in disj sig declarations
        if( converter != null )
          return converter.classes();
        return "";
    }

    //TODO: Construct SigClass and Sig Objects

    //Parse Functions
    public String ParseFunctions()
    {
        
            //Step 4:Rename uniquelly each Virtual function
            //Step 5:Add dispatching functions
            //Step 6:Replace super with an approriate static invocation
         if( converter != null )
          return converter.functions();
        return "";
              
    }
    
    //Parse Predicates
    public String ParsePredicates(){
        if( converter != null )
          return converter.predicates();
        return "";
      }

    //Extract Non-Converted Data
    public String NonConvertedData(){
      if( converter != null )
          return converter.everythingElse();
        return "";
    }

    //Parse classes and functions and return as a single result
    public String ParseClassesFunctions(){
      if( converter != null ){
          String strclasses = converter.classes();
          String strFunctions = converter.functions();

          return (strclasses + "\r\n" + strFunctions);
      }
        return "";
    }

     //Parse All
    //TODO: Do we need to make sure that classes, functions, predicates have already being done?
    public String ParserLexerExecute(String fileName){
      String parseResult = "";
      if( fileName.length() > 0){
          TestParser testParser = new TestParser();
          parseResult = testParser.ParseFile(fileName);

      }

        return parseResult;
    }


}
